			var user;
			var products;
			var product;
			var clients;
			var client;
			var salers;
			var purchaseList;
			var invoices;
			var contracts;
			var contract;
			var contractId;
			var amounts;
			var admins;
			var admin;
			var roles;
			var cg;
			var cgs;
			var address;
			var oldUrl;
			// hideMoudle();
			// xx();
			
			function getUser() {
				
				$.ajax({
					url:"sysUser/getUser",
					dataType:"json",
					type:"get",
					success:function(result){
						console.log(result);
						user = result.t;
						show();
					},
					error:function(xhr,error){
						console.log(xhr);
						console.log(error);
					}
				});
			}
			
			function xx(){
				$("#product-manage").show();
			}
			
			function hideMoudle(){
				$("#personal-performance").hide();//个人业绩
				$("#product-manage").hide();//产品管理
				$("#cargo-manage").hide();//货物管理
				$("#client-manage").hide();//客户管理
				$("#contract-manage").hide();//合同管理
				$("#sale-statistics").hide();//销售额统计
				$("#saler-manage").hide();//销售人员管理
				$("#admin-manage").hide();//权限管理
			}
			
			function loginUrl(){
				location.href = "login.html";
			}
			
			
			function logout(){
				$.ajax({
					url:"sysUser/logout",
					type:"get",
					dataType:"json",
					success:function(result){
						if (result.delete === true){
							loginUrl();
						}else{
							alertResult(result);
						}
					},
					error:function(xhr,err){
						console.log(err);
					}
				})
			}
			
			function backToUrl(){
				oldUrl = location.pathname+location.search;
				location.href = oldUrl;
			}
			
			function show(){
				userHandler();
				if (isAdminCenter()){
					doitUser();
				}else{
					doit();
				}
			}
			
			function doit(){
				displayModule();
			}
			
			function doitUser(){
				showUserMessageTable();
				showMessageTable();;
				displayModule();
			}
			
			function isAdminCenter(){
				let url = location.href;
				let realurl = url.substring(url.lastIndexOf("/")+1);
				if (realurl === "admin-center.html"){
					return true;
				}
				return false;
			}
			
			function userHandler() {
				//console.log(result);
				$(".username").text(user.username);
			}
			
			function displayModule(){
				let role = user.sysRole;
				if(role.roleName == "ROLE_SUPERADMIN"){
					$("#admin-manage").show();//权限管理
				}else if (role.roleName == "ROLE_SALEADMIN"){
					$("#product-manage").show();//产品管理
					$("#client-manage").show();//客户管理
					$("#contract-manage").show();//合同管理
					$("#sale-statistics").show();//销售额统计
					$("#saler-manage").show();//销售人员管理
				}else if (role.roleName == "ROLE_STOREADMIN"){
					$("#product-manage").show();//产品管理
					$("#cargo-manage").show();//货物管理
				}else if (role.roleName == "ROLE_SALER"){
					$("#personal-performance").show();//个人业绩
				}
			}
			
			
			function getQueryArgs(url) {
				var qs = (url.length > 0 ? url.substring(url.indexOf('?')).substr(1) : ''),
					//保存每一项
					args = {},
					//得到每一项
					items = qs.length ? qs.split('&') : [],
					item = null,
					name = null,
					value = null,
					i = 0,
					len = items.length;
			
				for (i = 0; i < len; i++) {
					item = items[i].split('='),
						name = decodeURIComponent(item[0])
					value = decodeURIComponent(item[1])
					if (name.length) {
						args[name] = value;
					}
				}
				return args;
			}
			
			function alertResult(result){
				alert(result.message);
			}
			
			